/*

Author   : chaos

FileName : com_rep.cpp

Date     : 16/08/17 17:38:08

*/
#include <iostream>
#include <string>

using namespace std;

void com_res(int);

int main(int argc ,char *argv[])
{
    string s1("string"), s2("string"),s3("ting");

    cout << "Using comparsion operator ..." << endl;
    if (s1>s2)
        cout << "s1 is after s2 !" << endl;
    else if(s1 > s2)
        cout << "s1 is before s2!" << endl;
    else
        cout << " s1 and s2 are the same!" << endl;

    cout << "Compare s1 and s2 ..." << endl;

    int result = s1.compare(s2);
    if(result == 0)
        cout << "Two strings are the same !" << endl;
    else if (result < 0)
        cout << "s1 is before s2 !" << endl;
    else
        cout << "s1 is after s2 !" << endl;

    cout << endl << "Compare s1[1-5] and s3 ..." << endl;
    result = s1.compare(1,5,s3);

    if (result ==0)
        cout << "s1[1-5] and s3 are the same !" << endl;
    else if(result < 0)
        cout << "s1[1-5] is before s3 !" << endl;
    else
        cout <<"s1[1-5] is false s3 !" << endl;

    cout << endl << "Find position of 'ing' substring in s1 : ";
    cout << s1.find("ing") << endl;

    s2.replace(s2.find("tring"),5,"TRING");

    cout << endl << "Replace s2's substing(tring) by 'TRING' ...";
    cout << endl << "s2 : " << s2 << endl;
    return 0;
}
